package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.system.controller.CxBase;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SafetyPublicityInfoMapper;
import com.ruoyi.system.domain.SafetyPublicityInfo;
import com.ruoyi.system.service.ISafetyPublicityInfoService;

/**
 * 安全宣传信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-04-07
 */
@Service
public class SafetyPublicityInfoServiceImpl extends CxBase implements ISafetyPublicityInfoService
{
    @Autowired
    private SafetyPublicityInfoMapper safetyPublicityInfoMapper;

    /**
     * 查询安全宣传信息
     * 
     * @param id 安全宣传信息ID
     * @return 安全宣传信息
     */
    @Override
    public SafetyPublicityInfo selectSafetyPublicityInfoById(Long id)
    {
        SafetyPublicityInfo safetyPublicityInfo = safetyPublicityInfoMapper.selectSafetyPublicityInfoById(id);
        safetyPublicityInfo.setSetDate(StampToString(Long.valueOf(safetyPublicityInfo.getSetDate())));
        return safetyPublicityInfo;
    }

    /**
     * 查询安全宣传信息列表
     * 
     * @param safetyPublicityInfo 安全宣传信息
     * @return 安全宣传信息
     */
    @Override
    public List<SafetyPublicityInfo> selectSafetyPublicityInfoList(SafetyPublicityInfo safetyPublicityInfo)
    {
        List<SafetyPublicityInfo> safetyPublicityInfos = safetyPublicityInfoMapper.selectSafetyPublicityInfoList(safetyPublicityInfo);
        if(safetyPublicityInfos.size()>0) {
            for (SafetyPublicityInfo safetyPublicityInfo1 : safetyPublicityInfos) {
                safetyPublicityInfo1.setSetDate(StampToString(Long.valueOf(safetyPublicityInfo1.getSetDate())));
            }
        }
        return safetyPublicityInfos;
    }

    /**
     * 新增安全宣传信息
     * 
     * @param safetyPublicityInfo 安全宣传信息
     * @return 结果
     */
    @Override
    public int insertSafetyPublicityInfo(SafetyPublicityInfo safetyPublicityInfo)
    {
        if(!checkNull(safetyPublicityInfo.getSetId())&&!checkNull(safetyPublicityInfo.getSafetyPublicityContent())&&!checkNull(safetyPublicityInfo.getSafetyPublicityPic())&&!checkNull(safetyPublicityInfo.getSafetyPublicityTitle())&&!checkNull(safetyPublicityInfo.getSafetyPublicityType())){
            safetyPublicityInfo.setSafetyPublicityId(getStamp().toString());
            safetyPublicityInfo.setSetDate(getStamp().toString());
            return safetyPublicityInfoMapper.insertSafetyPublicityInfo(safetyPublicityInfo);
        }
        return 0;
    }

    /**
     * 修改安全宣传信息
     * 
     * @param safetyPublicityInfo 安全宣传信息
     * @return 结果
     */
    @Override
    public int updateSafetyPublicityInfo(SafetyPublicityInfo safetyPublicityInfo)
    {
        if(!checkNull(safetyPublicityInfo.getSafetyPublicityType())&&!checkNull(safetyPublicityInfo.getSafetyPublicityTitle())&&!checkNull(safetyPublicityInfo.getSafetyPublicityPic())
        &&!checkNull(safetyPublicityInfo.getSafetyPublicityContent())){
            safetyPublicityInfo.setSafetyPublicityId(getStamp().toString());
            safetyPublicityInfo.setSetDate(getStamp().toString());
            return safetyPublicityInfoMapper.updateSafetyPublicityInfo(safetyPublicityInfo);
        }
        return 0;
    }

    /**
     * 批量删除安全宣传信息
     * 
     * @param ids 需要删除的安全宣传信息ID
     * @return 结果
     */
    @Override
    public int deleteSafetyPublicityInfoByIds(Long[] ids)
    {
        if(ids.length>0){
            return safetyPublicityInfoMapper.deleteSafetyPublicityInfoByIds(ids);
        }
        return 0;
    }

    /**
     * 删除安全宣传信息信息
     * 
     * @param id 安全宣传信息ID
     * @return 结果
     */
    @Override
    public int deleteSafetyPublicityInfoById(Long id)
    {
        return safetyPublicityInfoMapper.deleteSafetyPublicityInfoById(id);
    }
}
